<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<style>
/*.easyui-text-2{*/
	/*width: 140px; height: 25px;border-radius:5px;border:thin solid #ddd;*/
	/*border-color:#95B8E7;*/
/*}*/
/*.easyui-text-2:focus{*/
	/*outline: none;*/
/*}*/
</style>
<script type="text/javascript">
    $(function() {
        $('#sqlExcelQueryExpressionEditForm [name=type]').val("${sqlExcelQueryExpression.type}");
        $('#sqlExcelQueryExpressionEditForm').form({
            url : '${path}/sqlExcelQueryExpression/edit',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if (!isValid) {
                    progressClose();
                }
                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    showMsg(result.msg);
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    var form = $('#sqlExcelQueryExpressionEditForm');
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });


        $('#sqlExcelQueryExpressionEditForm [name=type]').change(function () {
            var val=$(this).val();
            if(val=='DownSelect'){
                var span='例如：a:b,c:d,e:f';
                $('.sqlExcelExAddCondition').closest('tr').remove();
                $(this).closest('tr').after('  <tr class="sqlExcelExAddCondition">'
                    + '                    <td>下拉选择条件</td>'
                    +'                    <td colspan="3">'
                    +'                        <input type="text" name="queryCondition" class="easyui-text-2" style="width:90%;">'
                    +'<br><div style="color:#999">'+span+'</div>'
                    +'                    </td>'
                    + '                </tr>');
            }else if(val=='defineSQL'){
                var span="输入sql语句";
                $(this).closest('tr').after(' <tr class="sqlExcelExAddCondition">'
                    + '                    <td>自定义SQL</td>'
                    +'                    <td colspan="3">'
                    +' <textarea name=\'querySql\'   placeholder=\'请输入\' class=\'easyui-text-2  span2 \'  style="width:90%;min-height:50px;" ></textarea>'
                    +'<br><div style="color:#999">'+span+'</div>'
                    +'                    </td>'
                    + '                </tr>');
            }else{
                $('.sqlExcelExAddCondition').closest('tr').remove();
            }
        })
    });
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow-x:hidden;overflow-y: auto;padding: 3px;">
        <form id="sqlExcelQueryExpressionEditForm" method="post">
            <input type="hidden" name="id" value="${sqlExcelQueryExpression.id}">
            <table class="grid">
                <tr>
                    <td>参数字段</td>
                    <td>
                        <input name='key' value="${sqlExcelQueryExpression.key}"  type='text' placeholder='请输入' class='easyui-text-2  span2 easyui-validatebox' data-options='required:true'  >
                    </td>
                    <td>名称</td>
                    <td>
                        <input name='name' value='${sqlExcelQueryExpression.name}'  type='text' placeholder='请输入名称' class='easyui-text-2  span2 easyui-validatebox' data-options='required:true' >
                        <input type='hidden' name='fid' id='fid' value="${sqlExcelQueryExpression.fid}">
                    </td>
                </tr>
                <tr>
                    <td>顺序</td>
                    <td>
                        <input name='seq' value="${sqlExcelQueryExpression.seq}"  type='number' placeholder='请输入顺序' class='easyui-text-2   span2 easyui-validatebox' data-options='required:true' >
                    </td>
                    <td>占位符</td>
                    <td>
                    <input name='placeholder' type='text' value="${sqlExcelQueryExpression.placeholder}" placeholder='请输入' class='easyui-text-2  span2 easyui-validatebox' data-options='required:true' >
                    </td>
                </tr> <tr>
                <td>类型</td>
                <td colspan="3">
                    <select name='type'  type='text'  class='easyui-text-2  span2 easyui-validatebox' data-options='required:true' >
                        <option value="">--请选择--</option>
                        <option value="String">字符串</option>
                        <option value="Date">日期</option>
                        <option value="DownSelect">下拉选择</option>
                        <option value="defineSQL">自定义SQL选择</option>
                        <option value="selectUser">选人</option>
                        <option value="selectOrg">选部门</option>
                        <option value="selectPosition">选职位</option>
                    </select>
                </td>
            </tr>
                <c:if test="${sqlExcelQueryExpression.type=='defineSQL'}">
                <tr class="sqlExcelExAddCondition">
                    <td>自定义SQL</td>
                    <td colspan="3">
                        <textarea name='querySql'   placeholder='请输入' class='easyui-text-2  span2'  style="width:90%;min-height:50px;" >${sqlExcelQueryExpression.querySql}</textarea>
                        <br><div style="color:#999">请输入自定义SQL</div>
                    </td>
                </tr>
                </c:if>
                <c:if test="${sqlExcelQueryExpression.type=='DownSelect'}">
                    <tr class="sqlExcelExAddCondition">
                        <td>下拉选择条件</td>
                        <td colspan="3">
                            <input type="text" name='queryCondition'   placeholder='请输入' class='easyui-text-2  span2'  style="width:90%;" value="${sqlExcelQueryExpression.queryCondition}"/>
                            <br><div style="color:#999">例如：a:b,c:d,e:f</div>
                        </td>
                    </tr>
                </c:if>
                <tr>
                    <td>替代占位符的表达式</td>
                    <td colspan="3">
                        <input name='expression' value='${sqlExcelQueryExpression.expression}'  type='text' placeholder='请输入表达式' class='easyui-text-2  span2 '  style="width:90%" >
                        <div style="color: #999;">
                            格式： and 参数名称=:参数名称<br>
                            例如：and name=:name
                        </div>
                    </td>
                </tr>

            </table>
        </form>
    </div>
</div>